package org.jfonia.musicxml.model;

import java.util.Set;
import java.util.TreeSet;

public class PartContext
{
//	private MyErrorHandler	errorHandler;

	private Set<Integer>		lyricsNumbers		= new TreeSet<Integer>();	// FORMERLY: =null; // not initialized

	private int				divisions				= 0;		// per quarter note; assumed constant throughout
	// each part!!

	private int				partDuration			= 0;		// running duration sum, needed for chords

	// public int measureTimeCounter = 0; // -> moved to Measure.duration
	private int				expectedMeasureDuration	= -1;

	private boolean			tiedToPrev				= false;	// the next note is tied to the current
	// note

	// public int harmoniesCount = 0;
	private boolean			containsNotes			= false;

	private boolean			containsChords			= false;
	
	private boolean         containsBackupOrForward = false;

	private boolean			containsGraceNotes		= false;

	private Measure			lastMeasure				= null;

	private Harmony			lastHarmony				= null;	// note: null indicates no chords found

	private boolean			transferBackward		= false; // transfer 'repeat-end' on volta-stop to next barline

	private boolean 		containsSecondVoiceWithNotes = false;
	
	public PartContext() // MyErrorHandler errorHandler)
	{
//		this.errorHandler = errorHandler;
	}

	public void updateHarmonyDuration()
	{
		if (lastHarmony != null)
			lastHarmony.setDuration(partDuration - lastHarmony.getStartTime());
	}

	public void setContainsChords(boolean containsChords)
	{
		this.containsChords = containsChords;
	}

	public boolean isContainsChords()
	{
		return containsChords;
	}

	public void setContainsGraceNotes(boolean containsGraceNotes)
	{
		this.containsGraceNotes = containsGraceNotes;
	}

	public boolean isContainsGraceNotes()
	{
		return containsGraceNotes;
	}

	public void setContainsNotes(boolean containsNotes)
	{
		this.containsNotes = containsNotes;
	}

	public boolean isContainsNotes()
	{
		return containsNotes;
	}

	public void setDivisions(int divisions)
	{
		this.divisions = divisions;
	}

	public int getDivisions()
	{
		return divisions;
	}

//	public void setErrorHandler(MyErrorHandler errorHandler)
//	{
//		this.errorHandler = errorHandler;
//	}
//
//	public MyErrorHandler getErrorHandler()
//	{
//		return errorHandler;
//	}

	public void setExpectedMeasureDuration(int expectedMeasureDuration)
	{
		this.expectedMeasureDuration = expectedMeasureDuration;
	}

	public int getExpectedMeasureDuration()
	{
		return expectedMeasureDuration;
	}

	public void setLastHarmony(Harmony lastHarmony)
	{
		this.lastHarmony = lastHarmony;
	}

	public Harmony getLastHarmony()
	{
		return lastHarmony;
	}

	public void setLastMeasure(Measure lastMeasure)
	{
		this.lastMeasure = lastMeasure;
	}

	public Measure getLastMeasure()
	{
		return lastMeasure;
	}

	public void setLyricsNumbers(Set<Integer> lyricsNumbers)
	{
		this.lyricsNumbers = lyricsNumbers;
	}

	public Set<Integer> getLyricsNumbers()
	{
		return lyricsNumbers;
	}

	public void setPartDuration(int partDuration)
	{
		this.partDuration = partDuration;
	}

	public int getPartDuration()
	{
		return partDuration;
	}

	public void setTiedToPrev(boolean tiedToPrev)
	{
		this.tiedToPrev = tiedToPrev;
	}

	public boolean isTiedToPrev()
	{
		return tiedToPrev;
	}

	public boolean isTransferBackward()
	{
		return transferBackward;
	}

	public void setTransferBackward(boolean transferBackward)
	{
		this.transferBackward = transferBackward;
	}

	public boolean isContainsBackupOrForward()
	{
		return containsBackupOrForward;
	}

	public void setContainsBackupOrForward(boolean containsBackupOrForward)
	{
		this.containsBackupOrForward = containsBackupOrForward;
	}

	public void setContainsSecondVoiceWithNotes(boolean b)
	{
		this.containsSecondVoiceWithNotes  = b;
	}

	public boolean isContainsSecondVoiceWithNotes()
	{
		return containsSecondVoiceWithNotes;
	}

}
